package cn.boundtw2.yccl.Demo01;

import java.io.FileNotFoundException;
import java.io.IOException;

public class Demo01TryCatch {


    public static void main(String[] args) {
        try {
            readFile("d:\\a.tx");
        } catch (IOException e) {
            System.out.println("传递的文件不是txt");
        }
    }


    public static void readFile(String fileName) throws IOException {

        if (!fileName.endsWith(".txt")) {
            throw new IOException("文件的后缀名错误");
        }
        System.out.println("文件没有问题");


    }
}
